package demoMod.stsconsole.commands;

import demoMod.stsconsole.dungeons.AbstractDungeon;
import demoMod.stsconsole.enums.ErrType;
import demoMod.stsconsole.helpers.*;
import demoMod.stsconsole.utils.ModLoader;
import javassist.CannotCompileException;

import java.lang.reflect.InvocationTargetException;
import java.util.Scanner;

public class Init extends AbstractCommand {
    private static boolean initialized = false;

    @Override
    public void execute(String[] args, Scanner sc) {
        if (args.length > 0) {
            this.errMsg(ErrType.WRONG_ARGUMENT);
            return;
        }
        if (!initialized) {
            try {
                ModLoader.loadClass();
            } catch (CannotCompileException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
                e.printStackTrace();
            }
            CharacterManager.initialize();
            AbstractDungeon.initialize();
            CardLibrary.initialize();
            RelicLibrary.initialize();
            PotionLibrary.initialize();
            MonsterHelper.initialize();
            new MonsterHelper();
            initialized = true;
            Mod.allowLoadMods = false;
        } else {
            this.errMsg(ErrType.COMMAND_NOT_AVAILABLE);
        }
    }

    @Override
    public boolean requiredPrompt(String currentPrompt) {
        return "".equals(currentPrompt);
    }
}
